ElementAtOrDefault(TSource) Method

Task Parallel System.Threading

Returns the element at a specified index in a parallel sequence or a default value if the index is out of range.

Namespace:  System.Linq
Assembly:  System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function ElementAtOrDefault(Of TSource) ( _
	source As ParallelQuery(Of TSource), _
	index As Integer _
) As TSource
C#
public static TSource ElementAtOrDefault<TSource>(
	ParallelQuery<TSource> source,
	int index
)

Parameters

source
Type: System.Linq..::.ParallelQuery<(Of <(TSource>)>)
A sequence to return an element from.
index
Type: System..::.Int32
The zero-based index of the element to retrieve.

Type Parameters

TSource
The type of the elements of source.

Return Value

default(TSource) if the index is outside the bounds of the source sequence; otherwise, the element at the specified position in the source sequence.

Exceptions

ExceptionCondition
System..::.ArgumentNullException source is a null reference (Nothing in Visual Basic).
System..::.AggregateException One or more exceptions occurred during the evaluation of the query.
System..::.OperationCanceledException The query was canceled.

See Also